<?php

class Application_Form_Order extends Validation_Form
{

  public function init()
  {
  	/*
  	 * data to form
  	 */
  	$subjectDao = new Application_Model_Dao_Subject();
  	$subjects = $subjectDao->getToSelect(); 
  	
  	$yearDao = new Application_Model_Dao_YearsStudent();
  	$years = $yearDao->getToSelectInformationAboutYear();
  	
  	$userDao = new Application_Model_Dao_User();
  	$lecturers = $userDao->getToSelectLecturers();
 	
  	/*
  	 * form
  	 */
    $this->setName("zendForm");
    $this->setMethod('post');
    
	$id = new Zend_Form_Element_Hidden('id');
	$id->addFilter('Int');

	$year = new Zend_Form_Element_Select('year_students_id');
   	$year->setLabel('Dla roku')
   	    		   ->setMultiOptions($years)
   	    		   ->setRequired(true)
   	    		   ->addValidator('NotEmpty', true);
	//$tutor->setLabel('Opiekun');
   	    		   
    $subject = new Zend_Form_Element_Select('subject_id');
   	$subject->setLabel('Przedmiot')
   	    		   ->setMultiOptions($subjects)
   	    		   ->setRequired(true)
   	    		   ->addValidator('NotEmpty', true);
   	    		   
   	$lecturer = new Zend_Form_Element_Select('lecturer_id');
   	$lecturer->setLabel('Wykładowca')
   	    		   ->setMultiOptions($lecturers)
   	    		   ->setRequired(true)
   	    		   ->addValidator('NotEmpty', true);
   	
    $numberWeek = $this->createElement('text','numberWeek');
    $numberWeek->setLabel('Liczba tygodni')
         ->setRequired(TRUE)
         ->setAttrib('size', 30)
         ->addFilters(array(
            new Zend_Filter_StringTrim(),
            new Zend_Filter_StripNewlines(),
			new Zend_Filter_StripTags()
           ))
         ->addValidators(array(
            new Zend_Validate_NotEmpty(),
            new Zend_Validate_Int()
            //new Zend_Validate_StringLength(array('min' => 2, 'max' => 30)),
            //new Zend_Validate_Alpha()
            ));
    $dimensionSemester = $this->createElement('text', 'dimensionSemester');
    $dimensionSemester->setLabel('Wymiar semestralny')
            ->setRequired(TRUE)
            ->setAttrib('size', 30)
            ->addFilters(array(
                new Zend_Filter_StringTrim(),
                new Zend_Filter_StripNewlines(),
                new Zend_Filter_StripTags()
            ))
            ->addValidators(array(
                new Zend_Validate_NotEmpty(),
                new Zend_Validate_Int()
                //new Zend_Validate_StringLength(array('min' => 2, 'max' => 30)),
                //new Zend_Validate_Alpha()
            ));
    $hourYear = $this->createElement('text', 'hourYear');
    $hourYear->setLabel('Liczba godzin na rok')
            ->setRequired(TRUE)
            ->setAttrib('size', 30)
            ->addFilters(array(
                new Zend_Filter_StringTrim(),
                new Zend_Filter_StripNewlines(),
                new Zend_Filter_StripTags()
            ))
            ->addValidators(array(
                new Zend_Validate_NotEmpty(),
                new Zend_Validate_Int()
                //new Zend_Validate_StringLength(array('min' => 2, 'max' => 30)),
                //new Zend_Validate_Alpha()
            ));
    $hourSemester = $this->createElement('text', 'hourSemester');
    $hourSemester->setLabel('Liczba godzin na semestr')
            ->setRequired(TRUE)
            ->setAttrib('size', 30)
            ->addFilters(array(
                new Zend_Filter_StringTrim(),
                new Zend_Filter_StripNewlines(),
                new Zend_Filter_StripTags()
            ))
            ->addValidators(array(
                new Zend_Validate_NotEmpty(),
                new Zend_Validate_Int()
                //new Zend_Validate_StringLength(array('min' => 2, 'max' => 30)),
                //new Zend_Validate_Alpha()
            ));
            
   	$submit = new Zend_Form_Element_Submit('submit');
	$submit->setAttrib('id', 'submit');
    
    $this->addElements(array(
    	$id,
        $year,
        //$tutor,
        
    	$subject,
    	$lecturer,
        $numberWeek,
        $dimensionSemester,
        $hourYear,
        $hourSemester,
        $submit,
     ));
  }


}

	